package org.example.mapper;

import org.example.model.ClassInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassMapper {
    @Insert("INSERT INTO class_info (name, teacher, create_time, update_time) VALUES (#{name}, #{teacher}, now(), now())")
    int insertClass(ClassInfo classInfo);

    @Update("UPDATE class_info SET name = #{name}, teacher = #{teacher}, update_time = now() WHERE id = #{id}")
    int updateClass(ClassInfo classInfo);

    @Delete("DELETE FROM class_info WHERE id = #{id}")
    int deleteClass(Long id);

    @Select("SELECT * FROM class_info WHERE id = #{id}")
    ClassInfo getClassById(Long id);

    @Select("SELECT * FROM class_info")
    List<ClassInfo> getAllClasses();
}